<template>
  <div>
    page is search
    <ul>
      <li v-for="(item, idx) in $store.state.city.list" :key="idx">{{item}}</li>
    </ul>
  </div>
</template>

<script>
  import axios from 'axios'

  export default {
    layout: 'search',
    data() {
      return {
        list: []
      }
    },
    async asyncData() {
      // 用fetch 主要是用来处理vuex的数据 用asyncData 是用来处理组件的数据
      // let self = this
      let {status, data: {list}} = await axios.get('http://localhost:3000/city/list')
      if (status === 200) {
        return {
          list
        }
      }
    }
  }
</script>
